package com.lemo.rest;

import com.lemo.bean.User;
import com.lemo.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.concurrent.atomic.AtomicLong;

@RestController
public class UserRest extends BaseRest {

    @Resource
    UserService userService;

    @Override
    @GetMapping("add")
    public String add() throws Exception {

        AtomicLong atomicLong = new AtomicLong();
        User user = new User();
        user.setUsername("9090");
        user.setMoney(new BigDecimal("33232.54"));
        return (userService.add(user) == Boolean.FALSE) ? "0" : "1";
    }

    @Override
    @GetMapping("del")
    public String del() {
        return (userService.del(00000000000000000004L) == Boolean.FALSE) ? "0" : "1";
    }

    @Override
    @GetMapping("update")
    public String update() throws Exception {
        User user = new User();
        user.setId(00000000000000000003L);
        user.setUsername("9091");
        user.setPassword("343455");
        return (userService.update(user) == Boolean.FALSE) ? "0" : "1";
    }

    @Override
    @GetMapping("get")
    public String get() throws Exception {
        return userService.get(00000000000000000002L).toString();
    }
}
